<link rel="stylesheet" href="__PUBLIC__/Js/CodeMirror/codemirror.css">
<link rel="stylesheet" href="__PUBLIC__/Js/CodeMirror/theme/mdn-like.css">
<script type="text/javascript" src="__PUBLIC__/Js/CodeMirror/codemirror.js"></script>
<script type="text/javascript" src="__PUBLIC__/Js/CodeMirror/xml.js"></script>
<script type="text/javascript" src="__PUBLIC__/Js/CodeMirror/javascript.js"></script>

<textarea id="{$name}" name="{$name}"></textarea>
<script type="text/javascript">
$(function(){
    var mirror_option = {
        mode: "application/xml",
        lineNumbers   :true,//显示行号
        indentUnit    :4,//缩进空格数
        smartIndent   :true,//智能缩进
        theme         :"mdn-like",//主题

        matchBrackets :true,
        gutter        :true,
        fixedGutter   :true,
        indentWithTabs:true,
        readOnly      :false,
        lineWrapping  :true,
        height        :500,
        enterMode     :"keep",
        tabMode       :"shift",
    };
    var mirror_area = document.getElementById("{$name}");
    var mirror = CodeMirror.fromTextArea(mirror_area, mirror_option);
    <notempty name="value">
    var mirror_data = {:json_encode($value)};
    mirror.setValue(mirror_data);
    </notempty>
});
</script>